﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dhtl.Service.IService;
using DataBase.Daihoctuonglai;
using Dhtl_Repositry.Repository;

namespace Dhtl.Service.Service
{
    public class Service_Roles : IRoles
    {
        public List<Role> List()
        {
            using (RolesRepositry Resp = new RolesRepositry())
            {
                return Resp.List();
            }
        }

        public int addOrupdate(Role entity)
        {
            using (RolesRepositry Resp = new RolesRepositry())
            {
                return Resp.CreateOrUpdate(entity);
            }
        }

        public void delete(int id)
        {
            using (RolesRepositry Resp = new RolesRepositry())
            {
                Resp.Delete(id);
            }
        }

        public string[] GetRolesForUser(string userName)
        {
            using (RolesRepositry Resp = new RolesRepositry())
            {
                return Resp.GetRolesForUser(userName);
            }
        }

        public void deleteByName(string Name)
        {
            using (RolesRepositry Resp = new RolesRepositry())
            {
                Resp.DeleRolesByName(Name);
            }
        }

        public Role GetById(int id)
        {
            using (RolesRepositry Resp = new RolesRepositry())
            {
                return Resp.GetById(id);
            }
        }

        public bool IsUserInRole(string username, string roleName)
        {
            using (RolesRepositry Resp = new RolesRepositry())
            {
                return Resp.IsUserInRole(username, roleName);
            }
        }
    }
}
